<!DOCTYPE html>
<html><head>
	    <meta charset="utf-8">
    <title>学无止境，耐得住寂寞的人最坚强！</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__ADMIN__/style/bootstrap.css" rel="stylesheet">
    <link href="__ADMIN__/style/font-awesome.css" rel="stylesheet">
    <link href="__ADMIN__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__ADMIN__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__ADMIN__/style/demo.css" rel="stylesheet">
    <link href="__ADMIN__/style/typicons.css" rel="stylesheet">
    <link href="__ADMIN__/style/animate.css" rel="stylesheet">

</head>
<body>
	<!-- 头部 -->
	   {include file="public/header"}
	<!-- /头部 -->
	
	<div class="main-container container-fluid">
		<div class="page-container">
			            <!-- Page Sidebar -->
            {include file="public/left"}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="{:url('index/index')}">系统</a>
                    </li>
                                        <li class="active">模型管理</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<button type="button" tooltip="添加模型" class="btn btn-sm btn-azure btn-addon" onClick="javascript:window.location.href = '{:url('model/add')}'"> <i class="fa fa-plus"></i> Add
</button>
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-body">
                <div class="flip-scroll">
                    <table class="table table-bordered table-hover">
                        <thead class="">
                            <tr>
                                <th width="4%" class="text-center">ID</th>
                                <th class="text-center">模型名称</th>
                                <th class="text-center">附加表名</th>
                                <th class="text-center">启用状态</th>
                                <th width="18%" class="text-center">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach name="data" id="model"}
                            <tr>
                                <td align="center">{$model.id}</td>
                                <td align="center">{$model.model_name}</td>
                                <td align="center">{$prefix}{$model.table_name}</td>
                                <td align="center">
                                <a modelid="{$model.id}" onclick="changestatus(this);" href="javascript:;" {if condition="$model.status eq 1"} class="btn btn-primary btn-sm shiny"  {else /} class="btn btn-danger btn-sm shiny" {/if} >
                                {if condition="$model.status eq 1"}  显示 {else /} 隐藏{/if} 
                                </a> </td>
                                <td align="center">
                                    <a href="{:url('model/edit',array('id'=>$model['id']))}" class="btn btn-primary btn-sm shiny">
                                        <i class="fa fa-edit"></i> 编辑
                                    </a>
                                    <a href="#" modelid="{$model.id}" onClick="del(this);"
                                        table_name="{$prefix}{$model.table_name}"
                                     class="btn btn-danger btn-sm shiny">
                                        <i class="fa fa-trash-o"></i> 删除
                                    </a>
                                </td>
                            </tr>
                            {/foreach}                            
                                                    
                       </tbody>
                    </table>
                </div>
                <div style="padding-top: 10px;text-align: center;">
                {$data->render()}
                 </div>
         
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>

	    <!--Basic Scripts-->
    <script src="__ADMIN__/style/jquery_002.js"></script>
    <script src="__ADMIN__/style/bootstrap.js"></script>
    <script src="__ADMIN__/style/jquery.js"></script>
    <script src="__ADMIN__/org/layer/layer.js"></script>
    <!--Beyond Scripts-->
    <script src="__ADMIN__/style/beyond.js"></script>
    <script>
    //修改状态栏ajax
        function changestatus(obj){
        var modelid=$(obj).attr("modelid");   
        $.ajax({
            type:"post",
            dataType:"json",
            data:{modelid:modelid},
            url:"{:url('model/changestatus')}",
            success:function(data){
                if(data ==1){
                    $(obj).attr('class',"btn btn-danger btn-sm shiny");
                    $(obj).text('隐藏');//有显示改为隐藏
                }else{
                    $(obj).attr('class',"btn btn-primary btn-sm shiny");
                    $(obj).text('显示');//有隐藏改为显示
                }
            }
        });
    }
    //ajax异步删除模型
    function del(obj){
         layer.confirm('确定要撤销图片吗？', {icon: 3, title:'提示'}, function(index){
               var modelid=$(obj).attr('modelid');
               var table_name=$(obj).attr("table_name");   
                    $.ajax({
                    type:"post",
                    dataType:"json",
                    data:{modelid:modelid,table_name:table_name},
                    url:"{:url('model/del')}",
                    success:function(data){
                        //alert(data);
                            if(data == 1){
                                layer.msg('删除模型成功！', {icon: 1});
                                window.location.href="{:url('model/lst')}";
                            }else{
                                layer.msg('删除模型失败！', {icon: 2});
                            }
                    }
                    });
          layer.close(index);
        });      

    }

    </script>


</body></html>